package com.heima.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum TaskStatus {
    TODO(1, "待办"),
    CARRYOUT(2, "进行"),
    CANCEL(3, "取消"),
    FINISH(4, "完成");

    @EnumValue
    final int value;
    final String desc;

    TaskStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static TaskStatus of(int value) throws Exception {
        if (value == 1) {
            return TODO;
        }
        if (value == 2) {
            return CARRYOUT;
        }
        if (value == 3) {
            return CANCEL;
        }
        if (value == 4) {
            return FINISH;
        }
        throw new Exception("工单状态错误");
    }
}
